<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ page import="com.beaut.project.util.StaticData" %>
<%@ include file="/public/header.jsp"%>
<%
    String callback = request.getParameter("callback");
	Map<String, Object> sessionMap = (Map<String, Object>) session.getAttribute("LOGIN_USER");
	String person_id = String.valueOf(sessionMap.get("id"));
	String person = String.valueOf(sessionMap.get("truename"));
%>
<html>
	<head>
		<title>员工借款管理</title>
	
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
			}
			.tdg{
			padding-top:10px;
			padding-bottom:5px;
			font-size: 12px;
			background-color: #c0ebd7;
			width:20%;
		}
		.tdb{
			padding:5px;
			width:30%;
		}
		</style>
	<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery("#searchValue").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
		});
			jQuery("#searchValue2").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch2();
		       	} 
		   	}); 
		$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
		jQuery('#user_id').combogrid({
				title:'借款人选择',
				mode:"remote",
				loadMsg:'正在加载数据，请稍后......',
				panelWidth:550,
				panelHeight:400,
				url:"<%=contextPath%>/springMVC/group/listPageUser",
				idField:"id",
				textField:"truename",
				rownumbers:true,
				fitColumns:true,
				columns: [[
					{field:'id',hidden:true},
					{field:'deptId',hidden:true},
					{field:'truename',title:'姓名',width:100},
					{field:'deptName',title:'所属部门',width:100},
					{field:'privName',title:'角色',width:100}
				]],
				toolbar:"#tba",
				pageSize:10,
				pageList:[10,50,100],  
				pagination:true,
				onChange:function(){
					doSearch();
				}
			});
			jQuery("#p_dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch2();
				}
			});
		jQuery("#table").datagrid({
			title:"员工借款",
			iconCls:'icon-zc',
			loadMsg:'正在加载数据，请稍后......',
			url:'<%=contextPath %>/springMVC/finance/listPageEmployee?zc_status=2',
			rownumbers:true,
			fitColumns:true,
			nowrap:false,
			idField:'id',
			frozenColumns:[[
			      //{field:'ck',checkbox:true},
			      {title:'主键',field:'id',hidden:true}
			]],
			columns:[[
				{title:'所属部门',field:'dept_name',width:100,align:'center'},
				{title:'员工名称',field:'employee_name',width:100,align:'center'},
				{title:'标题',field:'title',width:100,align:'center',sort:true},
				{title:'日期',field:'operation_date',width:100,align:'center',sort:true},
				{title:'借款金额',field:'money',width:100,align:'center'},
				{title:'已还金额',field:'already_money',width:100,align:'center'},
				{title:'当前状态',field:'status',width:60,align:'center',hidden:true},
				{title:'当前状态',field:'status_desc',width:60,align:'center'},
				{title:'摘要',field:'remark',width:200,align:'center'},
				{title:'选择操作',field:'more',width:80,align:'center',formatter:function(value,rowData,rowIndex){
					return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-ok' title='选择此项目' onclick=\"javascript:choseXm('"+rowData.id+"','"+rowData.employee_name+"','"+rowData.money+"');\"/>";
				}}
			]],
			onDblClickRow:function(rowIndex, rowData){
				choseXm(rowData.id,rowData.employee_name,rowData.money);
			},
			pageSize:10,
			pageList : [10,50,100],  
			pagination:true,
			onLoadSuccess:function(rtJson){
				if(rtJson.rtState== '1')
				{
					$.messager.alert('提示',rtJson.rtMsrg);
				}
			}
		});
			  
			});
	function rtCallBack(){
		$('#table').datagrid('reload');
	}
	function choseXm(id,employee_name,money){
			window.opener.rtCallBackEmployeeSet(id,employee_name,money);
			window.close();
	}
		
		function doSearch() {
			var dept_id = jQuery('#dept_id').combotree('getValue');
			var user_id = jQuery('#user_id').combotree('getValue');
			var searchValue = jQuery('#searchValue').val();
			$('#table').datagrid('load', {
				searchValue:searchValue,
				dept_id:dept_id,
				user_id:user_id
			});
		}
		function doSearch2() {
			var dept_id = jQuery('#p_dept_id').combotree('getValue');
			var searchValue = jQuery('#searchValue2').val();
			jQuery('#user_id').combogrid("grid").datagrid('load', {
				searchValue : searchValue,
				dept_id:dept_id
			});
		}
	</script>
	</head>
<body style="height: 97%">
		
					
							<div id="table"  data-options="toolbar:'#tb',fit:true"></div>  
								<div id="tb" style="padding:3px;height:auto">
								<div style="float:left;">
							</div>
						<div align="right">
							所属部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">&nbsp;&nbsp;
							借款人：<input type="text" id="user_id" name="user_id"   style="width:100px"> &nbsp;&nbsp;
							查询条件：<input id="searchValue" name="searchValue" style="width:150px" title="标题或者内容"  placeholder="标题或者内容"/>
								<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
								
						</div>
					</div>
					<div id="tba" style="padding:3px;height:auto">
			<div align="right">
			             所属部门：<input  id="p_dept_id" name="p_dept_id"  style="width:150px"  class="easyui-combotree">
				查询条件：<input id="searchValue2" name="searchValue2" style="width:150px" title="用户名称或者用户真实姓名"  placeholder="用户名称或者用户真实姓名"/>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch2();"></a>
			</div>
		</div>
	</body>
</html>